﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NewsDiscoveryEngine;
using NewsMine.DomainObjects;
using NewsMine.Storage;

namespace WebApp1.AdminSection
{
    public partial class WebSiteDetails : System.Web.UI.Page
    {
        public WebSiteInfo WebSiteInfo { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (WebApp1.Models.SecurityCheckManager.IsAdminPortalEabled() == false)
            {
                Response.Write("You should be the admin....");
                return;
            }


            var webStore = Defaults.WebSiteInfoMasterStore;


            string domain = this.Request.QueryString.Get("domain");
            string menuUrl = this.Request.QueryString.Get("url");

            //Response.Write("Domain is " + domain);
            //Response.Write("<br/>");
            //Response.Write("Menu Url  is " + menuUrl);

            WebSiteInfo webInfo = (WebSiteInfo) webStore.Get(domain);

            this.WebSiteInfo = webInfo;

            

 
            

        }

        public void GetFormMarkup()
        {
            Response.Write(GetFieldHtmlText("Name", this.WebSiteInfo.Name));
            Response.Write(GetFieldHtmlText("Local Name", this.WebSiteInfo.LocalName));
            Response.Write(GetFieldHtmlText("Tags", ""));
            Response.Write(GetFieldHtmlText("Language", this.WebSiteInfo.Language));
        }

        public string GetFieldHtmlText(string fieldName, string fieldValue)
        {
            return "<div class=\"control-group\"><label class=\"control-label\" for=\"{FName}\">{FName}</label><div class=\"controls\"><input type=\"text\" id=\"{FName}\" placeholder=\"{FName}\" value=\"{FValue}\"></div></div>".Replace("{FName}", fieldName).Replace("{FValue}", fieldValue);
        }

    }
}